package com.doge.util.converter;

import com.doge.exception.Param402Exception;
import lombok.SneakyThrows;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: doge
 * @description:
 * @author: Keyu Li
 * @create: 2021-12-01 14:03
 **/

@Component
public class DateConverter implements Converter<String, Date> {
    @SneakyThrows
    @Override
    public  Date convert(String source) {
        Date date=null;
        try {
            date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(source);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
        return date;
    }
}
